package com.upic.serviceImpl;

import com.upic.po.UserExaminationQuestions;
import com.upic.repository.UserExaminationQuestionsRepository;
import com.upic.service.UserExaminationQuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YeTian
 * @date 2018/2/7/007
 */
@Service("userExaminationQuestionsService")
public class UserExaminationQuestionsServiceImpl implements UserExaminationQuestionsService {

    @Autowired
    private UserExaminationQuestionsRepository userExaminationQuestionsRepository;

    @Override
    public UserExaminationQuestions saveUserExaminationQuestions(UserExaminationQuestions userExaminationQuestions) {
        return userExaminationQuestionsRepository.save(userExaminationQuestions);
    }

    @Override
    public String deleteUserExaminationQuestions(long userExaminationQuestionsId) {
        userExaminationQuestionsRepository.delete(userExaminationQuestionsId);
        return "SUCCESS";
    }

    @Override
    public Page<UserExaminationQuestions> searchUserExaminationQuestions(Pageable pageable) {
        return userExaminationQuestionsRepository.findAll(pageable);
    }

    @Override
    public List<UserExaminationQuestions> searchUserExaminationQuestions() {
        return userExaminationQuestionsRepository.findAll();
    }

    @Override
    public UserExaminationQuestions findOne(long userExaminationQuestionsId) {
        return userExaminationQuestionsRepository.findOne(userExaminationQuestionsId);
    }

    @Override
    public UserExaminationQuestions updateUserExaminationQuestions(UserExaminationQuestions userExaminationQuestions) {
        return userExaminationQuestionsRepository.saveAndFlush(userExaminationQuestions);
    }
}
